﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DTO;
using BUS;
using DAO;
namespace QL_Lichvantai
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }

        private void bt_login_Click(object sender, EventArgs e)
        {
            Nhanvien_DTO nv = new Nhanvien_DTO();
            try
            {
                if (rd_nofix.Checked == true) 
                {                   
                    DataProvider.SetDatabase("QLLVANTAI");
                }
                else
                {
                    DataProvider.SetDatabase("QLLVANTAI_FIX");                
                }
                
                Nhanvien_BUS login = new Nhanvien_BUS();  
                string User = txt_user.Text.ToString();
                string Pass = txt_pass.Text.ToString();

                nv = login.Dangnhap(User, Pass);
               
                MessageBox.Show(nv.Msg);
                if (nv.Vaitro == "0")
                {
                    frm_Quanly frm = new frm_Quanly();
                    frm.Show();
                }
                if (nv.Vaitro == "1" || nv.Vaitro == "2")
                {
                    frm_Nhanvien frm = new frm_Nhanvien();
                    frm.GetData(nv);
                    frm.Show();
                }
            }
            catch (System.Exception ex)
            {
                if (nv.Msg != null)
                {
                    MessageBox.Show(nv.Msg);                             
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

       
       
    }
}
